package com.ruoyi.archive.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.archive.domain.SFormIdentity;
import com.ruoyi.archive.enums.SoldierFormEnum;
import com.ruoyi.archive.mapper.SFormIdentityMapper;
import com.ruoyi.archive.service.ISFormIdentityService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: ruoyi
 * @description:
 * @author: yuxiang
 * @create: 2021-10-09 11:25
 */
@Service
public class SFormIdentityServiceImpl extends ServiceImpl<SFormIdentityMapper, SFormIdentity> implements ISFormIdentityService {

    @Override
    public Map<String, List<SFormIdentity>> getFormList() {
        Map<String, List<SFormIdentity>> map = new HashMap<>();
        List<SFormIdentity> generalList = getGeneralList();
        List<SFormIdentity> exclusiveList = getExclusiveList();
        List<SFormIdentity> relativeList = getRelativeList();
        List<SFormIdentity> disablesTypeList = getDisablesType();
        map.put("generalList", generalList);
        map.put("exclusiveList", exclusiveList);
        map.put("relativeList", relativeList);
        map.put("disablesTypeList", disablesTypeList);
        return map;
    }

    public List<SFormIdentity> getDisablesType() {
        List<SFormIdentity> disablesTypeList = baseMapper.selectList(new QueryWrapper<SFormIdentity>().lambda().likeRight(SFormIdentity::getFormNo, SoldierFormEnum.DISABLED_TYPE.getValue()));
        return disablesTypeList;
    }

    public List<SFormIdentity> getGeneralList() {
        List<SFormIdentity> generalList = baseMapper.selectList(new QueryWrapper<SFormIdentity>().lambda().likeRight(SFormIdentity::getFormNo, SoldierFormEnum.GENERAL.getValue()));
        return generalList;
    }

    public List<SFormIdentity> getExclusiveList() {
        List<SFormIdentity> exclusiveList = baseMapper.selectList(new QueryWrapper<SFormIdentity>().lambda().likeRight(SFormIdentity::getFormNo, SoldierFormEnum.EXCLUSIVE.getValue()));
        return exclusiveList;
    }

    public List<SFormIdentity> getRelativeList() {
        List<SFormIdentity> relativeList = baseMapper.selectList(new QueryWrapper<SFormIdentity>().lambda().likeRight(SFormIdentity::getFormNo, SoldierFormEnum.RELATIVE.getValue()));
        return relativeList;
    }
}
